#@layoutT("供应商")
#define main()
#@formStart()
#@queryStart('用户名')
<input type="search" name="userCode" autocomplete="off" class="layui-input" placeholder="用户名"/>
#@queryEnd()
#@queryStart('姓名')
<input type="search" name="userName" autocomplete="off" class="layui-input" placeholder="姓名"/>
#@queryEnd()
#@queryStart('部门')
<select name="orgId" class="layui-input" lay-search>
    <option value="">---请选择部门---</option>
    #for(data:orgList)
    <option value="#(data.value??)">#(data.text??)</option>
    #end
</select>
#@queryEnd()

#@queryStart('性别')
<select name="sex" class="layui-input" lay-search>
    <option value="">---请选择性别---</option>
    <option value="1">男</option>
    <option value="0">女</option>
</select>
#@queryEnd()

#@formEnd()

<div class='layui-row f-index-toolbar'>
    <div class='layui-col-xs12'>
        <div class="layui-btn-group">
            <button id='addBtn_' class="layui-btn layui-btn-normal layui-btn-sm">
                <i class="layui-icon">&#xe608;</i> 新增
            </button>
            <button id='deleteBtn_' class="layui-btn  layui-btn-normal layui-btn-sm">
                <i class="layui-icon">&#xe640;</i> 删除
            </button>
        </div>
    </div>
</div>
<div class="layui-row  f-index-toolbar">
    <div class="layui-col-xs12">
        <table id="maingrid" lay-filter="maingrid"></table>
    </div>
</div>

<!-- 	每行的操作按钮 -->
<script type="text/html" id="bar_maingrid">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
</script>
#end

#define layuiFunc()
    //监听行单击事件（双击事件为：rowDouble）
    table.on('row(maingrid)', function(obj){
        var data = obj.data;

        //标注选中样式
        obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');

        // 弹窗回调值绑定
        callbackdata = function () {
            var res = {
                supplierId: data.supplier_id,
                supplierName:data.supplier_name,
            };
            return res;
        }
    });
#end

#define js()
<!-- 分页表格 -->
<script type="text/javascript">
    var callbackdata;

    $(function(){
        getSupplierList();
    })

    function getSupplierList(){
        gridArgs.title='物品';
        gridArgs.dataId='supplier_id';
        gridArgs.deleteUrl='#(path)/erp/info/supplier/delete?primaryKey='+gridArgs.dataId;
        gridArgs.updateUrl='#(path)/erp/info/supplier/edit?primaryKey=';
        gridArgs.addUrl='#(path)/erp/info/supplier/add';
        gridArgs.gridDivId ='maingrid';
        initGrid({id : 'maingrid'
            ,elem : '#maingrid'
            ,cellMinWidth: 80
            ,cols : [ [
                {title: '主键',field : 'supplier_id',width : 35,checkbox : true},
                {title:'序号',type:'numbers',width:35},
                {title: '客户名称', field: 'supplier_name' },
                {title: '联系电话', field: 'phone'},
                {title: '邮箱', field: 'email'},
                {title: '地址', field: 'addr'},
                {title: '操作',fixed:'right',width : 180,align : 'left',toolbar : '#bar_maingrid'} // 这里的toolbar值是模板元素的选择器
            ] ]
            ,url:"#(path)/erp/info/supplier/list"
            ,where:{"object":"sys_tree","primaryKey":gridArgs.dataId}
            ,searchForm : 'searchForm'
        },null);
    }

</script>
#end